var Setup = {
   data: null,
   init: function(winData) {
      this.data = winData;
      if (!this.data.configURL) {
         var dirService = Components.classes['@mozilla.org/file/directory_service;1'].getService(Components.interfaces.nsIProperties);
         var workspaceFile = dirService.get("UChrm", Components.interfaces.nsILocalFile);
         workspaceFile.appendRelativePath("workspaces.xml");
         var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
         var url = ioService.newFileURI(workspaceFile);
         document.getElementById('location').value = url.spec;
      } else {
         document.getElementById('default-type').value = this.data.defaultType;
         document.getElementById('auto-title').checked = this.data.autoTitle;
         document.getElementById('location').value = this.data.configURL;
      }
   },
   browseForFile: function()
   {
      var nsIFilePicker = Components.interfaces.nsIFilePicker;
      var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
      fp.init(window, "Choose a File to Store Your Workspaces", nsIFilePicker.modeOpen);
      if (fp.show() == nsIFilePicker.returnOK) {
         document.getElementById('location').value = fp.fileURL.spec;
      }
   },
   browseForDir: function()
   {
      var nsIFilePicker = Components.interfaces.nsIFilePicker;
      var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
      fp.init(window, "Choose a Directory to Store Your Workspaces", nsIFilePicker.modeGetFolder);
      if (fp.show() == nsIFilePicker.returnOK) {
         var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
         file.initWithFile(fp.file);
         file.appendRelativePath("atomic-config.xml");
         var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
         var url = ioService.newFileURI(file);
         document.getElementById('location').value = url.spec;
      }
   },

   finish: function() {
      this.data.configURL = document.getElementById('location').value;
      this.data.autoTitle = document.getElementById('auto-title').checked;
      this.data.defaultType = document.getElementById('default-type').value;
      this.data.ok = true;
   },
   cancel: function() {
      this.data.ok = false;
   }
   
}